home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 12
/
Amiga Plus Sonderheft Amiga 12.iso
/
pd
/
spiele
/
klondike_adptools
/
install
/
datas
/
english.lha
/
4-RenderCards.adpro
< prev
next >
Wrap
Text File
|
1997-08-22
|
28KB
|
1,228 lines
/*
** RenderCards.adpro :
**
** This ARexx script for ADPro v2.5 or higher,
** load 52 scaled pictures, global palette, 52 symbols pictures, render & save them to IFF HAM8 88x130
**
** Klondike & Reko Tools © Copyright Reko Productions - All Rights Reserved.
**
** $VER: RenderCards/English v2.0 (16.06.97) Copyright © 1995-97 Lejardinier Olivier - All Rights Reserved
**
*/
/*
** ARexx Initializations.
*/
ADDRESS "ADPro"
OPTIONS RESULTS
ReturnCode = 0
/*
** Parse Arguments.
*/
PARSE ARG Mode
/*
** Constants Initializations.
*/
NL = '0A'X
DNL = NL || NL
FALSE = 0
TRUE = 1
/*
** Strings initializations.
*/
TITLE_Error = "Error :"
TITLE_Request = "Request :"
TITLE_Confirm = "Confirm :"
TITLE_Infos = "Informations :"
TITLE_SelectScaledPic = "Select 1 scaled picture :"
TITLE_SelectSymbolPic = "Select 1 symbol picture :"
TITLE_SelectPalette = "Select global palette :"
TITLE_SelectCardPicsDir = "Select cards pictures destination :"
TITLE_EnterCardPicsBaseName = "Enter cardset name to create :"
TITLE_SelectCardsetType = "Choose cardset type :"
TITLE_SelectExtraPic = "Select extra picture"
MSG_Abort = "Abort ?"
MSG_ErrorCode = "Error code ="
MSG_ADProResult = "ADPro result ="
MSG_UnableToSaveADProPrefs = "Unable to save ADPro prefs."
MSG_UnableToRestoreADProPrefs = "Unable to restore ADPro prefs."
MSG_WhatCardsToRender = "What kind of cards do you want to create ?"
MSG_YouMustSelectScaledPic = "You MUST select 1 scaled picture !"
MSG_UnableToLoadScaledPic = "Unable to load scaled picture :"
MSG_CheckingScaledPic = "Checking scaled picture :"
MSG_InvalidScaledPic = "Invalid scaled picture size"
MSG_MissingScaledPic = "Some scaled pictures are missing"
MSG_YouMustSelectSymbolPic = "You MUST select 1 symbol picture !"
MSG_UnableToLoadSymbolPic = "Unable to load symbol picture :"
MSG_CheckingSymbolPic = "Checking symbol picture :"
MSG_InvalidSymbolPic = "Invalid symbol picture size"
MSG_MissingSymbolPic = "Some symbols pictures are missing"
MSG_UnableToLoadPalette = "Unable to load palette :"
MSG_UnableToExtractPaletteInfos = "Unable to extract color 0 from palette :"
MSG_Processing = "Processing"
MSG_CreatingBackdropPic = "Creating backdrop picture"
MSG_ComposingWithScaledPic = "Composing with scaled picture"
MSG_RenderingCardPass1 = "Rendering : Pass 1"
MSG_ComposingWithSymbolPic = "Composing with symbol picture"
MSG_RenderingCardPass2 = "Rendering : Pass 2"
MSG_SavingCard = "Saving card picture"
MSG_UnableToCreateBackdropPic = "Unable to create backdrop picture"
MSG_UnableToRenderScaledPic = "Unable to render card picture (Pass 1)"
MSG_UnableToRenderCardPic = "Unable to render card picture ( Pass 2)"
MSG_UnableToSaveCardPic = "Unable to save card picture :"
MSG_CarsetType = "What kind of cardset do you want to create ?" || DNL || "55 cards (standard)" || NL || "59 cards (extra cards)"
MSG_CheckingCardPic = "Checking card picture :"
MSG_UnableToLoadExtraPic = "Unable to load extra picture :"
MSG_CheckingExtraPic = "Checking extra picture"
MSG_InvalidExtraPicSizeSmall = "Extra picture size too small"
MSG_InvalidExtraPicSizeBig = "Exrta picture size too big"
MSG_UnableToScaleExtraPic = "Unable to scale extra picture :"
MSG_UnableToSaveExtraCardPic = "Unable to save extra card picture :"
GAD_Abort = "Abort"
GAD_ContinueAbort = "Continue|Abort"
GAD_AllNormalExtraAbort = "All|Normals|Extras|Abort"
GAD_SelectAbort = "Select|Abort"
GAD_Quit = "Quit"
GAD_RetrySelectAbort = "Retry|Select|Abort"
GAD_RetryAbort = "Retry|Abort"
GAD_RetrySkipAbort = "Retry|Skip|Abort"
GAD_StdExtAbort = "55 cards|59 cards|Abort"
GAD_ScaleSelectAbort = "Scale|Select|Abort"
/*
** Save the current ADPro environment.
*/
TempDefaults = "T:TempADProDefaults"
SAVE_DEFAULTS '"'TempDefaults'"'
IF ( RC ~= 0 ) THEN
DO
Text = MSG_UnableToSaveADProPrefs || MSG_ADProError ADPRO_RESULT
OKAY1 '"'Text'"'
END
/*
** Initializations of new ADPro environment.
*/
CLOSE_RENDER_SCREEN
CLEAR_RENDERED
CLEAR_RAW
PSTATUS "UNLOCKED"
DISPLAYMESSAGE '""'
ADPRO_TO_FRONT
/*
** Menu.
*/
IF ( Mode = "AUTO" ) THEN
RenderCardsType = 1
ELSE
DO
Continue = FALSE
DO UNTIL ( Continue = TRUE )
OKAYN '"'TITLE_Request'"' '"'MSG_WhatCardsToRender'"' '"'GAD_AllNormalExtraAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
ELSE
DO
RenderCardsType = RC
Continue = TRUE
END
END
END
/*
** Get a previously scaled picture and check it.
*/
ScaledPicsDir = GetPref( "KADPT.ScaledPicsDir" )
IF ( RenderCardsType < 3 ) THEN
DO
IF ( ( Mode = "AUTO" ) & ( ScaledPicsDir ~= "" ) ) THEN
DO
ScaledPicsBaseName = GetPref( "KADPT.ScaledPicsBaseName" )
ScaledPicPath = AddPart( ScaledPicsDir, AddExt( ScaledPicsBaseName, "001" ) )
RetVal = CheckScaledPics( ScaledPicPath )
IF ( WORD( RetVal, 1 ) ~= 52 ) THEN
DO
ReturnCode = 10
CALL Quit
END
END
ELSE
DO
Continue = FALSE
DO UNTIL ( Continue = TRUE )
IF ( ScaledPicsDir ~= "" ) THEN
GETFILE '"'TITLE_SelectScaledPic'"' '"'ParseDir( ScaledPicsDir )'"' '""'
ELSE
GETFILE '"'TITLE_SelectScaledPic'"'
IF ( RC ~= 0 ) THEN
DO
OKAYN '"'TITLE_Error'"' '"'MSG_YouMustSelectScaledPic'"' '"'GAD_SelectAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
END
ELSE
DO
ScaledPicPath = ADPRO_RESULT
RetVal = CheckScaledPics( ScaledPicPath )
IF ( WORD( RetVal, 1 ) = 52 ) THEN
DO
SetPref( "KADPT.ScaledPicsDir", WORD( RetVal, 2 ) )
Continue = TRUE
END
END
END
END
ScaledPicsDir = WORD( RetVal, 2 )
ScaledPicsBaseName = WORD( RetVal, 3 )
NbScaledPics = WORD( RetVal, 1 )
END
/*
** Get global palette.
*/
PalettePath = GetPref( "KADPT.PalettePath" )
IF ( ( Mode = "AUTO" ) & ( PalettePath ~= "" ) ) THEN
DO
PaletteCol0 = GetPaletteCol0( PalettePath )
IF ( PaletteCol0 = "" ) THEN
DO
ReturnCode = 10
CALL Quit
END
END
ELSE
DO
IF ( PalettePath = "" ) THEN
DO
PaletteDir = ScaledPicsDir
PaletteName = AddExt( ScaledPicsBaseName, "Palette" )
END
ELSE
DO
PaletteDir = DirPart( PalettePath )
PaletteName = FilePart( PalettePath )
END
Continue = FALSE
DO UNTIL ( Continue = TRUE )
GETFILE '"'TITLE_SelectPalette'"' '"'ParseDir( PaletteDir )'"' '"'ParseString( PaletteName )'"'
IF ( RC ~= 0 ) THEN
CALL ConfirmAbort
ELSE
DO
PalettePath = ADPRO_RESULT
PaletteCol0 = GetPaletteCol0( PalettePath )
IF ( PaletteCol0 ~= "" ) THEN
DO
SetPref( "KADPT.PalettePath", PalettePath )
Continue = TRUE
END
END
END
END
PSTATUS "LOCKED"
/*
** Get a symbol file and check it.
*/
SymbolPicsDir = GetPref( "KADPT.SymbolPicsDir" )
IF ( RenderCardsType < 3 ) THEN
DO
Continue = FALSE
DO UNTIL ( Continue = TRUE )
IF ( SymbolPicsDir ~= "" ) THEN
GETFILE '"'TITLE_SelectSymbolPic'"' '"'ParseDir( SymbolPicsDir )'"' '""'
ELSE
GETFILE '"'TITLE_SelectSymbolPic'"'
IF ( RC ~= 0 ) THEN
DO
OKAYN '"'TITLE_Error'"' '"'MSG_YouMustSelectSymbolPic'"' '"'GAD_SelectAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
END
ELSE
DO
SymbolPicPath = ADPRO_RESULT
Text = MSG_CheckingSymbolPic FilePart( SymbolPicPath )
DISPLAYMESSAGE '"'Text'"'
LOAD_TYPE "REPLACE"
Continue0 = FALSE
DO UNTIL ( Continue0 = TRUE )
LOADER "IFF" SymbolPicPath
IF ( RC ~= 0 ) THEN
DO
IF ( ADPRO_RESULT = "Aborted" ) THEN
CALL ConfirmAbort
ELSE
DO
Text = MSG_UnableToLoadSymbolPic || DNL || ParseString( SymbolPicPath ) || ADProResult()
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_RetrySelectAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
ELSE
IF ( RC = 2 ) THEN
Continue0 = TRUE
END
END
ELSE
DO
XSIZE
SymbolPicWidth = ADPRO_RESULT
YSIZE
SymbolPicHeight = ADPRO_RESULT
IF ( ( SymbolPicWidth = 88 ) & ( SymbolPicHeight = 130 ) ) THEN
DO
PPOKE 0
IF ( RC ~= 0 ) THEN
DO
Text = MSG_UnableToGetColor || DNL || ParseString( SymbolPicPath ) || ADProResult()
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_SelectAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
END
ELSE
DO
SymbolPicCol0 = ADPRO_RESULT
SymbolPicsDir = DirPart( SymbolPicPath )
SymbolPicsBaseName = DelExt( FilePart( SymbolPicPath ) )
Found = TRUE
NbSymbolPics = 0
Extension = 11
DO UNTIL ( Found = FALSE )
FileExtension = RIGHT( Extension, 3, '0' )
SymbolPicPath = AddPart( SymbolPicsDir, AddExt( SymbolPicsBaseName, FileExtension ) )
Text = MSG_CheckingSymbolPic FilePart( SymbolPicPath )
DISPLAYMESSAGE '"'Text'"'
IF ( EXISTS( SymbolPicPath ) ) THEN
DO
NbSymbolPics = NbSymbolPics + 1
IF ( RIGHT( FileExtension, 1 ) = '4' ) THEN
Extension = Extension + 7
ELSE
Extension = Extension + 1
END
ELSE
Found = FALSE
END
DISPLAYMESSAGE '""'
IF ( NbSymbolPics = 52 ) THEN
DO
Continue0 = TRUE
Continue = TRUE
END
ELSE
DO
OKAYN '"'TITLE_Error'"' '"'MSG_MissingSymbolPic'"' '"'GAD_SelectAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
Continue0 = TRUE
END
END
END
ELSE
DO
OKAYN '"'TITLE_Error'"' '"'MSG_InvalidSymbolPicSize'"' '"'GAD_SelectAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
Continue0 = TRUE
END
END
END
END
END
SetPref( "KADPT.SymbolPicsDir", SymbolPicsDir )
END
/*
** Get output directory for cards pictures.
*/
CardPicsDir = GetPref( "KADPT.CardPicsDir" )
IF ( CardPicsDir = "" ) THEN
CardPicsDir = ScaledPicsDir
IF ( RenderCardsType ~= 2 ) THEN
DO
Continue = FALSE
DO UNTIL ( Continue = TRUE )
IF ( CardPicsDir ~= "" ) THEN
GETDIR '"'TITLE_SelectCardPicsDir'"' '"'ParseDir( CardPicsDir )'"'
ELSE
GETDIR '"'TITLE_SelectCardPicsDir'"'
IF ( RC ~= 0 ) THEN
CALL ConfirmAbort
ELSE
DO
CardPicsDir = ADPRO_RESULT
Continue = TRUE
END
END
SetPref( "KADPT.CardPicsDir", CardPicsDir )
END
/*
** Get card pics base name.
*/
CardPicsBaseName = GetPref( "KADPT.CardPicsBaseName" )
IF ( CardPicsBaseName = "" ) THEN
CardPicsBaseName = "Card"
Continue = FALSE
DO UNTIL ( Continue = TRUE )
GETSTRING '"'TITLE_EnterCardPicsBaseName'"' '"'CardPicsBaseName'"'
IF ( RC ~= 0 ) THEN
CALL ConfirmAbort
ELSE
DO
CardPicsBaseName = ADPRO_RESULT
Continue = TRUE
END
END
SetPref( "KADPT.CardPicsBaseName", CardPicsBaseName )
/*
** Initializaztions before creating cards pictures.
*/
SET_RENDER_MODE Amiga 167940 88 130 HAM8
/*
** Create normals cards pictures.
*/
IF ( RenderCardsType < 3 ) THEN
DO
ScaledPic = 1
SymbolPic = 11
DO CardPic = 3 TO 54
CardPicPath = AddPart( CardPicsDir, AddExt( CardPicsBaseName, RIGHT( CardPic, 3, '0' ) ) )
Processing = MSG_Processing FilePart( CardPicPath )
/*
** Compose a backdrop picture with a scaled picture
*/
Continue = FALSE
DO UNTIL ( Continue = TRUE)
/*
** Create backdrop picture.
*/
Text = Processing MSG_CreatingBackdropPic
DISPLAYMESSAGE '"'Text'"'
LOAD_TYPE "REPLACE"
Continue0 = FALSE
DO UNTIL ( Continue0 = TRUE )
LOADER "BACKDROP" "XXX" "WIDTH" 88 "HEIGHT" 130 PaletteCol0 "COLOR"
IF ( RC ~= 0 ) THEN
DO
IF ( ADPRO_RESULT = "Aborted" ) THEN
CALL ConfirmAbort
ELSE
DO
Text = MSG_UnableToCreateBackdropPic || ADProResult()
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_RetryAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
END
END
ELSE
Continue0 = TRUE
END
/*
** Compose with scaled picture.
*/
ScaledPicPath = AddPart( ScaledPicsDir, AddExt( ScaledPicsBaseName, RIGHT( ScaledPic, 3, '0' ) ) )
Text = Processing MSG_ComposingWithScaledPic FilePart( ScaledPicPath )
DISPLAYMESSAGE '"'Text'"'
LOAD_TYPE "COMPOSE"
LOADER "IFF" ScaledPicPath 1 1 100 -1 -1 -1
IF ( RC ~= 0 ) THEN
DO
IF ( ADPRO_RESULT = "Aborted" ) THEN
CALL ConfirmAbort
ELSE
DO
Text = MSG_UnableToLoadScaledPic || DNL || ParseString( ScaledPicPath ) || ADProResult()
IF ( NbScaledPics <= ( 52 - CardPic + 3 ) ) THEN
DO
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_RetryAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
END
ELSE
DO
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_RetrySkipAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
ELSE
IF ( RC = 2 ) THEN
DO
ScaledPic = ScaledPic + 1
NbScaledPics = NbScaledPics - 1
END
END
END
END
ELSE
DO
Continue = TRUE
ScaledPic = ScaledPic + 1
NbScaledPics = NbScaledPics - 1
END
END
/*
** Render backdrop picture + scaled picture
*/
Text = Processing MSG_RenderingCardPass1
DISPLAYMESSAGE '"'Text'"'
DITHER 1
Continue = FALSE
DO UNTIL ( Continue = TRUE )
EXECUTE
IF ( RC ~= 0 ) THEN
DO
IF ( ADPRO_RESULT = "Aborted" ) THEN
CALL ConfirmAbort
ELSE
DO
Text = MSG_UnableToRenderScaledPic || DNL || ParseString( ScaledPicPath ) || ADProResult()
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_RetryAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
END
END
ELSE
Continue = TRUE
END
/*
** Convert result to 24 bits
*/
Continue = FALSE
DO UNTIL ( Continue = TRUE )
OPERATOR "Rendered_To_Raw"
IF ( RC ~= 0 ) THEN
DO
IF ( ADPRO_RESULT = "Aborted" ) THEN
CALL ConfirmAbort
ELSE
DO
Text = MSG_UnableToRenderScaledPic || DNL || ParseString( ScaledPicPath ) || ADProResult()
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_RetryAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
END
END
ELSE
Continue = TRUE
END
/*
** Compose with symbol picture.
*/
SymbolPicPath = AddPart( SymbolPicsDir, AddExt( SymbolPicsBaseName, RIGHT( SymbolPic, 3, '0' ) ) )
IF ( RIGHT( SymbolPicPath, 1 ) = '4' ) THEN
SymbolPic = SymbolPic + 7
ELSE
SymbolPic = SymbolPic + 1
Text = Processing MSG_ComposingWithSymbolPic FilePart( SymbolPicPath )
DISPLAYMESSAGE '"'Text'"'
LOAD_TYPE "COMPOSE"
Continue = FALSE
DO UNTIL ( Continue = TRUE )
LOADER "IFF" SymbolPicPath 0 0 100 SymbolPicCol0
IF ( RC ~= 0 ) THEN
DO
IF ( ADPRO_RESULT = "Aborted" ) THEN
CALL ConfirmAbort
ELSE
DO
Text = MSG_UnableToLoadSymbolPic || DNL || ParseString( SymbolPicPath || ADProResult()
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_RetryAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
END
END
ELSE
Continue = TRUE
END
/*
** Render backdrop picture + scaled picture + symbol picture
*/
Text = Processing MSG_RenderingCardPass2
DISPLAYMESSAGE '"'Text'"'
DITHER 0
Continue = FALSE
DO UNTIL ( Continue = TRUE )
EXECUTE
IF ( RC ~= 0 ) THEN
DO
IF ( ADPRO_RESULT = "Aborted" ) THEN
CALL ConfirmAbort
ELSE
DO
Text = MSG_UnableToRenderCardPic || DNL || ParseString( CardPicPath ) || ADProResult()
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_RetryAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
END
END
ELSE
Continue = TRUE
END
/*
** Save card picture.
*/
Text = Processing MSG_SavingCard
DISPLAYMESSAGE '"'Text'"'
Continue = FALSE
DO UNTIL ( Continue = TRUE )
SAVER "IFF" CardPicPath "IMAGE"
IF ( RC ~= 0 ) THEN
DO
IF ( ADPRO_RESULT = "Aborted" ) THEN
CALL ConfirmAbort
ELSE
DO
Text = MSG_UnableToSaveCardPic || DNL || ParseString( CardPicPath ) || ADProResult()
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_RetryAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
END
END
ELSE
Continue = TRUE
END
END
END
/*
** Get type of cardset.
*/
IF ( RenderCardsType ~= 2 ) THEN
DO
Continue = FALSE
DO UNTIL ( Continue = TRUE )
OKAYN '"'TITLE_SelectCardsetType'"' '"'MSG_CarsetType'"' '"'GAD_StdExtAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
ELSE
DO
IF ( RC = 1 ) THEN
NumberOfCards = 55
ELSE
NumberOfCards = 59
Continue = TRUE
END
END
END
/*
** Render extras cards Card00->Card02 (& Card55->Card58).
*/
IF ( ( RenderCardsType = 1 ) | ( RenderCardsType = 3 ) ) THEN
DO
ExtraPicPath = ""
CALL CreateExtraCards 0 2 FALSE
IF ( RC ~= 0 ) THEN
CALL Quit
ELSE
CALL CreateExtraCards 2 1 TRUE
IF ( NumberOfCards = 59 ) THEN
DO
CALL CreateExtraCards 55 4 TRUE
IF ( RC ~= 0 ) THEN
CALL Quit
END
END
/*
** Quit.
*/
Quit:
CLOSE_RENDER_SCREEN
CLEAR_RENDERED
CLEAR_RAW
DISPLAYMESSAGE '""'
IF ( EXISTS( TempDefaults ) ) THEN
DO
LOAD_DEFAULTS '"'TempDefaults'"'
IF ( RC ~= 0 ) THEN
DO
Text = MSG_UnableToRestoreADProPrefs || ADProResult()
OKAY1 '"'Text'"'
END
ADDRESS COMMAND 'C:Delete >NIL: FILE="' || TempDefaults || '" QUIET'
END
EXIT ReturnCode
RETURN
/*
** Functions.
*/
CheckScaledPics:
PARSE ARG ScaledPicPath
RetVal = "0"
Text = MSG_CheckingScaledPic FilePart( ScaledPicPath )
DISPLAYMESSAGE '"'Text'"'
LOAD_TYPE "REPLACE"
Continue01 = FALSE
DO UNTIL ( Continue01 = TRUE )
LOADER "IFF" ScaledPicPath
IF ( RC ~= 0 ) THEN
DO
IF ( ADPRO_RESULT = "Aborted" ) THEN
CALL ConfirmAbort
ELSE
DO
Text = MSG_UnableToLoadScaledPic || DNL || ParseString( ScaledPicPath ) || ADProResult()
IF ( Mode = "AUTO" ) THEN
Gad = GAD_RetryAbort
ELSE
Gad = GAD_RetrySelectAbort
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'Gad'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort "NOCHECK"
ELSE
IF ( RC = 2 ) THEN
Continue01 = TRUE
END
END
ELSE
DO
XSIZE
ScaledPicWidth = ADPRO_RESULT
YSIZE
ScaledPicHeight = ADPRO_RESULT
IF ( ( ScaledPicWidth = 86 ) & ( ScaledPicHeight = 128 ) ) THEN
DO
ScaledPicsDir = DirPart( ScaledPicPath )
ScaledPicsBaseName = DelExt( FilePart( ScaledPicPath ) )
Continue02 = TRUE
NbScaledPics = 0
Extension = 1
DO UNTIL ( ( Continue02 = FALSE ) | ( NbScaledPics = 52 ) )
FileExtension = RIGHT( Extension, 3, '0' )
ScaledPicPath = AddPart( ScaledPicsDir, AddExt( ScaledPicsBaseName, FileExtension ) )
Text = MSG_CheckingScaledPic FilePart( ScaledPicPath )
DISPLAYMESSAGE '"'Text'"'
IF ( EXISTS( ScaledPicPath ) ) THEN
DO
NbScaledPics = NbScaledPics + 1
Extension = Extension + 1
END
ELSE
Continue02 = FALSE
END
DISPLAYMESSAGE '""'
IF ( NbScaledPics = 52 ) THEN
DO
RetVal = NbScaledPics ScaledPicsDir ScaledPicsBaseName
Continue01 = TRUE
END
ELSE
DO
Text = MSG_MissingScaledPic || DNL || ScaledPicPath
IF ( Mode = "AUTO" ) THEN
Gad = GAD_Abort
ELSE
Gad = GAD_SelectAbort
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'Gad'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort "NOCHECK"
Continue01 = TRUE
END
END
ELSE
DO
Text = MSG_InvalidScaledPicSize || DNL || ScaledPicPath
IF ( Mode = "AUTO" ) THEN
Gad = GAD_Abort
ELSE
Gad = GAD_SelectAbort
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'Gad'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort "NOCHECK"
Continue01 = TRUE
END
END
END
RETURN RetVal
GetPaletteCol0:
PARSE ARG PalettePath
PaletteCol0 = ""
PLOAD PalettePath
IF ( RC ~= 0 ) THEN
DO
IF ( ADPRO_RESULT = "Aborted" ) THEN
CALL ConfirmAbort "NOCHECK"
ELSE
DO
Text = MSG_UnableToLoadPalette || DNL || ParseString( PalettePath ) || ADProResult()
IF ( Mode = "AUTO" ) THEN
Gad = GAD_Abort
ELSE
Gad = GAD_SelectAbort
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'Gad'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort "NOCHECK"
END
END
ELSE
DO
PPOKE 0
IF ( RC ~= 0 ) THEN
DO
Text = MSG_UnableToExtractPaletteInfos || DNL || ParseString( PalettePath ) || ADProResult()
IF ( Mode = "AUTO" ) THEN
Gad = GAD_Abort
ELSE
Gad = GAD_SelectAbort
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'Gad'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
END
ELSE
DO
PaletteCol0 = ADPRO_RESULT
Continue = TRUE
END
END
RETURN PaletteCol0
CreateExtraCards:
PARSE ARG CardPicStart NbCardPics DitherMode
ExtraPicsDir = GetPref( "KADPT.ExtraPicsDir" )
IF ( ExtraPicsDir = "" ) THEN
ExtraPicsDir = SymbolPicsDir
DO CardPic = CardPicStart TO ( CardPicStart + NbCardPics - 1 )
Continue = FALSE
DO UNTIL ( Continue = TRUE )
Title = TITLE_SelectExtraPic AddExt( CardPicsBaseName, RIGHT( CardPic, 3, '0' ) ) ":"
GETFILE '"'Title'"' '"'ParseDir( ExtraPicsDir )'"' '"'FilePart( ExtraPicPath )'"'
IF ( RC ~= 0 ) THEN
CALL ConfirmAbort
ELSE
DO
ExtraPicPath = ADPRO_RESULT
ExtraPicsDir = DirPart( ExtraPicPath )
SetPref( "KADPT.ExtraPicsDir", ExtraPicsDir )
Text = MSG_CheckingExtraPic FilePart( ExtraPicPath )
DISPLAYMESSAGE '"'Text'"'
LOAD_TYPE "REPLACE"
Continue0 = FALSE
DO UNTIL ( Continue0 = TRUE )
LOADER "UNIVERSAL" ExtraPicPath
IF ( RC ~= 0 ) THEN
DO
Text = MSG_UnableToLoadExtraPic || DNL || ParseString( ExtraPicPath ) || ADProResult()
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_RetrySelectAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
ELSE
IF ( RC = 2 ) THEN
Continue0 = TRUE
END
ELSE
DO
Continue1 = FALSE
XSIZE
ExtraPicWidth = ADPRO_RESULT
YSIZE
ExtraPicHeight = ADPRO_RESULT
IF ( ( ExtraPicWidth < 88 ) & ( ExtraPicHeight < 130 ) ) THEN
DO
Text = MSG_InvalidExtraPicSizeSmall || DNL || ParseString( ExtraPicPath )
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_SelectAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
Continue0 = TRUE
END
ELSE
IF ( ( ExtraPicWidth > 88 ) | ( ExtraPicHeight > 130 ) ) THEN
DO
Text = MSG_InvalidExtraPicSizeBig || DNL || ParseString( ExtraPicPath )
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_ScaleSelectAbort'"'
IF ( RC = 0 ) THEN
DO
CALL ConfirmAbort
Continue0 = TRUE
END
ELSE
IF ( RC = 1 ) THEN
DO
Continue2 = FALSE
DO UNTIL ( Continue2 = TRUE )
ABS_SCALE 88 130
IF ( RC ~= 0 ) THEN
DO
Text = MSG_UnableToScaleExtraPic || DNL || ParseString( ExtraPicPath ) || ADProResult()
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_SelectAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
Continue2 = TRUE
Continue0 = TRUE
END
ELSE
DO
Continue2 = TRUE
Continue1 = TRUE
Continue0 = TRUE
END
END
END
ELSE
Continue0 = TRUE
END
ELSE
DO
Continue1 = TRUE
Continue0 = TRUE
END
IF ( Continue1 = TRUE ) THEN
DO
DITHER DitherMode
Continue2 = FALSE
DO UNTIL ( Continue2 = TRUE )
EXECUTE
IF ( RC ~= 0 ) THEN
DO
IF ( ADPRO_RESULT = "Aborted" ) THEN
CALL ConfirmAbort
ELSE
DO
Text = MSG_UnableToCreateExtraPic || DNL || ParseString( ExtraPicPath ) || ADProResult()
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_RetryAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
END
END
ELSE
Continue2 = TRUE
CardPicPath = AddPart( CardPicsDir, AddExt( CardPicsBaseName, RIGHT( CardPic, 3, '0' ) ) )
Continue2 = FALSE
DO UNTIL ( Continue1 = TRUE )
SAVER "IFF" CardPicPath "IMAGE"
IF ( RC ~= 0 ) THEN
DO
IF ( ADPRO_RESULT = "Aborted" ) THEN
CALL ConfirmAbort
ELSE
DO
Text = MSG_UnableToSaveExtraCardPic || DNL || ParseString( CardPicPath ) || ADProResult()
OKAYN '"'TITLE_Error'"' '"'Text'"' '"'GAD_RetryAbort'"'
IF ( RC = 0 ) THEN
CALL ConfirmAbort
END
END
ELSE
DO
Continue2 = TRUE
Continue1 = TRUE
Continue0 = TRUE
Continue = TRUE
END
END
END
END
END
END
END
END
END
RETURN 0
/*
** Sub Routines
*/
ADProResult:
ADProResultText = DNL || MSG_ErrorCode RC || NL || MSG_ADProResult ADPRO_RESULT
RETURN ADProResultText
ConfirmAbort:
PARSE ARG Check
IF ( ( Mode = "AUTO" ) & ( Check = "NOCHECK" ) ) THEN
DO
ReturnCode = 20
CALL Quit
END
ELSE
DO
OKAYN '"'TITLE_Confirm'"' '"'MSG_Abort'"' '"'GAD_ContinueAbort'"'
IF ( RC = 0 ) THEN
DO
ReturnCode = 20
CALL Quit
END
RETURN
ParseString: PROCEDURE
PARSE ARG String
RETURN STRIP( String, 'B', '"' )
ParseDir: PROCEDURE
PARSE ARG Dir
Dir = ParseString( Dir )
Dir = STRIP( Dir, 'T', '/' )
RETURN Dir
DirPart: PROCEDURE
PARSE ARG Path
Path = ParseString( Path )
FNameSepPos = LASTPOS( '/', Path )
IF ( FNameSepPos = 0 ) THEN
RETURN LEFT( Path, LASTPOS( ':', Path ) )
ELSE
RETURN LEFT( Path, FNameSepPos - 1 )
FilePart:
PARSE ARG Path
Path = ParseString( Path )
FNameSepPos = LASTPOS( '/', Path )
IF ( FNameSepPos = 0 ) THEN
FNameSepPos = LASTPOS( ':', Path )
RETURN RIGHT( Path, LENGTH( Path ) - FNameSepPos )
AddPart:
PARSE ARG Dir, Name
LastChar = RIGHT( Dir, 1 )
IF (( LastChar ~= "/" ) & ( LastChar ~= ":" )) THEN
Dir = Dir || "/"
RETURN Dir || Name
AddExt:
PARSE ARG Name, Ext
RETURN Name || "." || Ext
DelExt:
PARSE ARG Name
PointPos = LASTPOS( '.', Name )
if ( PointPos ~= 0 ) THEN
Name = DELSTR( Name, PointPos )
RETURN Name
GetPref: PROCEDURE
PARSE ARG Name
Pref = GETCLIP( Name )
IF ( Pref = "" ) THEN
DO
IF ( OPEN( FileHandle, AddPart( "ENVARC:Klondike_ADPTools", Name ), "READ" ) ) THEN
DO
Pref = READLN( FileHandle )
Dummy = CLOSE( FileHandle )
END
END
RETURN Pref
SetPref: PROCEDURE
PARSE ARG Name, Pref
Dummy = SETCLIP( Name, Pref )
IF ( ~EXISTS( "ENVARC:Klondike_ADPTools" ) ) THEN
ADDRESS COMMAND 'C:MakeDir >NIL: ENVARC:Klondike_ADPTools'
IF ( OPEN( FileHandle, AddPart( "ENVARC:Klondike_ADPTools", Name ), "WRITE" ) ) THEN
DO
Dummy = WRITELN( FileHandle, Pref )
Dummy = CLOSE( FileHandle )
END
RETURN Pref